package validator;

import model.SysUsers;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

public class MyValidator implements Validator {
    @Override
    public boolean supports(Class<?> clazz) {
        return SysUsers.class.equals(clazz);
    }

    @Override
    public void validate(Object target, Errors errors) {
        SysUsers users = (SysUsers) target;
        if(users.getStatus()!=0&&users.getStatus()!=1){
            errors.rejectValue("status","状态只能是0或1！");
        }
    }
}
